//
//  HTClassCustomLabel.swift
//  QuitSmokingApp
//
//  Created by z on 2024/3/17.
//

import UIKit

class HTClassCustomLabel: UILabel {

    var var_strokeColor: UIColor = .black
    
    var var_strokeWidth: CGFloat = 0.0
    
    override func draw(_ rect: CGRect) {
        if self.var_strokeWidth > 0 {
            
            let var_shadowOffset = self.shadowOffset;
            let var_textColor = self.textColor;
            
            let var_c = UIGraphicsGetCurrentContext();
            var_c!.setLineWidth(self.var_strokeWidth);
            var_c!.setLineJoin(.round)
            //画外边
            var_c!.setTextDrawingMode(.stroke)
            self.textColor = self.var_strokeColor;
            super.draw(rect)
            //画内文字
            var_c!.setTextDrawingMode(.fill)
            self.textColor = var_textColor;
            self.shadowOffset = CGSizeMake(0, 0);
            super.draw(rect)
            self.shadowOffset = var_shadowOffset;
        } else {
            super.draw(rect)
        }
    }
}
